home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_emacs.idb / usr / freeware / share / emacs / 19.34 / lisp / iso-cvt.el.z / iso-cvt.el
Encoding:
Text File  |  1998-10-28  |  17.2 KB  |  718 lines

  1. ;;; iso-cvt.el --- translate to ISO 8859-1 from/to net/TeX conventions
  2. ;; This file was formerly called gm-lingo.el.
  3.  
  4. ;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
  5.  
  6. ;; Author: Michael Gschwind <mike@vlsivie.tuwien.ac.at>
  7. ;; Keywords: tex, iso, latin, i18n
  8.  
  9. ;; This file is part of GNU Emacs.
  10.  
  11. ;; GNU Emacs is free software; you can redistribute it and/or modify
  12. ;; it under the terms of the GNU General Public License as published by
  13. ;; the Free Software Foundation; either version 2, or (at your option)
  14. ;; any later version.
  15.  
  16. ;; GNU Emacs is distributed in the hope that it will be useful,
  17. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. ;; GNU General Public License for more details.
  20.  
  21. ;; You should have received a copy of the GNU General Public License
  22. ;; along with GNU Emacs; see the file COPYING.  If not, write to the
  23. ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  24. ;; Boston, MA 02111-1307, USA.
  25.  
  26. ;;; Commentary: 
  27.  
  28. ;; This lisp code serves two purposes, both of which involve 
  29. ;; the translation of various conventions for representing European 
  30. ;; character sets to ISO 8859-1.
  31.  
  32. ;; Net support: 
  33. ;; Various conventions exist in Newsgroups on how to represent national 
  34. ;; characters. The functions provided here translate these net conventions 
  35. ;; to ISO.
  36. ;;
  37. ;; Calling `iso-german' will turn the net convention for umlauts ("a etc.) 
  38. ;; into ISO latin1 umlauts for easy reading.
  39. ;; 'iso-spanish' will turn net conventions for representing spanish 
  40. ;; to ISO latin1. (Note that accents are omitted in news posts most 
  41. ;; of the time, only enye is escaped.)
  42.  
  43. ;; TeX support
  44. ;; This mode installs hooks which change TeX files to ISO Latin-1 for 
  45. ;; simplified editing. When the TeX file is saved, ISO latin1 characters are
  46. ;; translated back to escape sequences.
  47. ;;
  48. ;; An alternative is a TeX style that handles 8 bit ISO files 
  49. ;; (available on ftp.vlsivie.tuwien.ac.at in /pub/8bit)  
  50. ;; - but these files are difficult to transmit ... so while the net is  
  51. ;; still @ 7 bit this may be useful
  52.  
  53. ;;; TO DO:
  54. ;; The net support should install hooks (like TeX support does) 
  55. ;; which recognizes certain news groups and translates all articles from 
  56. ;; those groups. 
  57. ;;
  58. ;; Cover more cases for translation (There is an infinite number of ways to 
  59. ;; represent accented characters in TeX)
  60.  
  61. ;;; SEE ALSO:
  62. ;; If you are interested in questions related to using the ISO 8859-1 
  63. ;; characters set (configuring emacs, Unix, etc. to use ISO), then you
  64. ;; can get the ISO 8859-1 FAQ via anonymous ftp from 
  65. ;; ftp.vlsivie.tuwien.ac.at in /pub/bit/FAQ-ISO-8859-1
  66.  
  67. ;;; Code:
  68.  
  69. (provide 'iso-cvt)
  70.  
  71. (defvar iso-spanish-trans-tab
  72.   '(
  73.     ("~n" "±")
  74.     ("\([a-zA-Z]\)#" "\\1±")
  75.     ("~N" "╤")
  76.     ("\\([-a-zA-Z\"`]\\)\"u" "\\1ⁿ")
  77.     ("\\([-a-zA-Z\"`]\\)\"U" "\\1▄")
  78.     ("\\([-a-zA-Z]\\)'o" "\\1≤")
  79.     ("\\([-a-zA-Z]\\)'O" "\\╙")
  80.     ("\\([-a-zA-Z]\\)'e" "\\1Θ")
  81.     ("\\([-a-zA-Z]\\)'E" "\\1╔")
  82.     ("\\([-a-zA-Z]\\)'a" "\\1ß")
  83.     ("\\([-a-zA-Z]\\)'A" "\\1A")
  84.     ("\\([-a-zA-Z]\\)'i" "\\1φ")
  85.     ("\\([-a-zA-Z]\\)'I" "\\1═")
  86.     )
  87.   "Spanish translation table.")
  88.  
  89. (defun iso-translate-conventions (trans-tab)
  90.   "Use the translation table TRANS-TAB to translate the current buffer."
  91.   (save-excursion
  92.     (goto-char (point-min))
  93.     (let ((work-tab trans-tab)
  94.       (buffer-read-only nil)
  95.       (case-fold-search nil))
  96.       (while work-tab
  97.     (save-excursion
  98.       (let ((trans-this (car work-tab)))
  99.         (while (re-search-forward (car trans-this) nil t)
  100.           (replace-match (car (cdr trans-this)) t nil)))
  101.       (setq work-tab (cdr work-tab)))))))
  102.  
  103. (defun iso-spanish ()
  104.   "Translate net conventions for Spanish to ISO 8859-1."
  105.   (interactive)
  106.   (iso-translate-conventions iso-spanish-trans-tab))
  107.  
  108. (defvar iso-aggressive-german-trans-tab
  109.   '(
  110.     ("\"a" "Σ")
  111.     ("\"A" "─")
  112.     ("\"o" "÷")
  113.     ("\"O" "╓")
  114.     ("\"u" "ⁿ")
  115.     ("\"U" "▄")
  116.     ("\"s" "▀")
  117.     ("\\\\3" "▀")
  118.     )
  119.   "German translation table. 
  120. This table uses an aggressive translation approach and may erroneously
  121. translate too much.")
  122.  
  123. (defvar iso-conservative-german-trans-tab
  124.   '(
  125.     ("\\([-a-zA-Z\"`]\\)\"a" "\\1Σ")
  126.     ("\\([-a-zA-Z\"`]\\)\"A" "\\1─")
  127.     ("\\([-a-zA-Z\"`]\\)\"o" "\\1÷")
  128.     ("\\([-a-zA-Z\"`]\\)\"O" "\\1╓")
  129.     ("\\([-a-zA-Z\"`]\\)\"u" "\\1ⁿ")
  130.     ("\\([-a-zA-Z\"`]\\)\"U" "\\1▄")
  131.     ("\\([-a-zA-Z\"`]\\)\"s" "\\1▀")
  132.     ("\\([-a-zA-Z\"`]\\)\\\\3" "\\1▀")
  133.     )
  134.   "German translation table.
  135. This table uses a conservative translation approach and may translate too 
  136. little.")
  137.  
  138.  
  139. (defvar iso-german-trans-tab iso-aggressive-german-trans-tab 
  140.   "Currently active translation table for German.")
  141.  
  142. (defun iso-german ()
  143.  "Translate net conventions for German to ISO 8859-1."
  144.  (interactive)
  145.  (iso-translate-conventions iso-german-trans-tab))
  146.  
  147. (defvar iso-iso2tex-trans-tab
  148.   '(
  149.     ("Σ" "{\\\\\"a}")
  150.     ("α" "{\\\\`a}")
  151.     ("ß" "{\\\\'a}")
  152.     ("π" "{\\\\~a}")
  153.     ("Γ" "{\\\\^a}")
  154.     ("δ" "{\\\\\"e}")
  155.     ("Φ" "{\\\\`e}")
  156.     ("Θ" "{\\\\'e}")
  157.     ("Ω" "{\\\\^e}")
  158.     ("∩" "{\\\\\"\\\\i}")
  159.     ("∞" "{\\\\`\\\\i}")
  160.     ("φ" "{\\\\'\\\\i}")
  161.     ("ε" "{\\\\^\\\\i}")
  162.     ("÷" "{\\\\\"o}")
  163.     ("≥" "{\\\\`o}")
  164.     ("≤" "{\\\\'o}")
  165.     ("⌡" "{\\\\~o}")
  166.     ("⌠" "{\\\\^o}")
  167.     ("ⁿ" "{\\\\\"u}")
  168.     ("∙" "{\\\\`u}")
  169.     ("·" "{\\\\'u}")
  170.     ("√" "{\\\\^u}")
  171.     ("─" "{\\\\\"A}")
  172.     ("└" "{\\\\`A}")
  173.     ("┴" "{\\\\'A}")
  174.     ("├" "{\\\\~A}")
  175.     ("┬" "{\\\\^A}")
  176.     ("╦" "{\\\\\"E}")
  177.     ("╚" "{\\\\`E}")
  178.     ("╔" "{\\\\'E}")
  179.     ("╩" "{\\\\^E}")
  180.     ("╧" "{\\\\\"I}")
  181.     ("╠" "{\\\\`I}")
  182.     ("═" "{\\\\'I}")
  183.     ("╬" "{\\\\^I}")
  184.     ("╓" "{\\\\\"O}")
  185.     ("╥" "{\\\\`O}")
  186.     ("╙" "{\\\\'O}")
  187.     ("╒" "{\\\\~O}")
  188.     ("╘" "{\\\\^O}")
  189.     ("▄" "{\\\\\"U}")
  190.     ("┘" "{\\\\`U}")
  191.     ("┌" "{\\\\'U}")
  192.     ("█" "{\\\\^U}")
  193.     ("±" "{\\\\~n}")
  194.     ("╤" "{\\\\~N}")
  195.     ("τ" "{\\\\c c}")
  196.     ("╟" "{\\\\c C}")
  197.     ("▀" "{\\\\ss}")
  198.     ("\306" "{\\\\AE}")
  199.     ("\346" "{\\\\ae}")
  200.     ("\305" "{\\\\AA}")
  201.     ("\345" "{\\\\aa}")
  202.     ("\251" "{\\\\copyright}")
  203.     ("ú" "{\\\\pounds}")
  204.     ("╢" "{\\\\P}")
  205.     ("º" "{\\\\S}")
  206.     ("┐" "{?`}")
  207.     ("í" "{!`}")
  208.     )
  209.   "Translation table for translating ISO 8859-1 characters to TeX sequences.")
  210.  
  211.  
  212.  
  213.  
  214. (defun iso-iso2tex ()
  215.  "Translate ISO 8859-1 characters to TeX sequences."
  216.  (interactive)
  217.  (iso-translate-conventions iso-iso2tex-trans-tab))
  218.  
  219.  
  220. (defvar iso-tex2iso-trans-tab
  221.   '(
  222.     ("{\\\\\"a}" "Σ")
  223.     ("{\\\\`a}" "α")
  224.     ("{\\\\'a}" "ß")
  225.     ("{\\\\~a}" "π")
  226.     ("{\\\\^a}" "Γ")
  227.     ("{\\\\\"e}" "δ")
  228.     ("{\\\\`e}" "Φ")
  229.     ("{\\\\'e}" "Θ")
  230.     ("{\\\\^e}" "Ω")
  231.     ("{\\\\\"\\\\i}" "∩")
  232.     ("{\\\\`\\\\i}" "∞")
  233.     ("{\\\\'\\\\i}" "φ")
  234.     ("{\\\\^\\\\i}" "ε")
  235.     ("{\\\\\"i}" "∩")
  236.     ("{\\\\`i}" "∞")
  237.     ("{\\\\'i}" "φ")
  238.     ("{\\\\^i}" "ε")
  239.     ("{\\\\\"o}" "÷")
  240.     ("{\\\\`o}" "≥")
  241.     ("{\\\\'o}" "≤")
  242.     ("{\\\\~o}" "⌡")
  243.     ("{\\\\^o}" "⌠")
  244.     ("{\\\\\"u}" "ⁿ")
  245.     ("{\\\\`u}" "∙")
  246.     ("{\\\\'u}" "·")
  247.     ("{\\\\^u}" "√")
  248.     ("{\\\\\"A}" "─")
  249.     ("{\\\\`A}" "└")
  250.     ("{\\\\'A}" "┴")
  251.     ("{\\\\~A}" "├")
  252.     ("{\\\\^A}" "┬")
  253.     ("{\\\\\"E}" "╦")
  254.     ("{\\\\`E}" "╚")
  255.     ("{\\\\'E}" "╔")
  256.     ("{\\\\^E}" "╩")
  257.     ("{\\\\\"I}" "╧")
  258.     ("{\\\\`I}" "╠")
  259.     ("{\\\\'I}" "═")
  260.     ("{\\\\^I}" "╬")
  261.     ("{\\\\\"O}" "╓")
  262.     ("{\\\\`O}" "╥")
  263.     ("{\\\\'O}" "╙")
  264.     ("{\\\\~O}" "╒")
  265.     ("{\\\\^O}" "╘")
  266.     ("{\\\\\"U}" "▄")
  267.     ("{\\\\`U}" "┘")
  268.     ("{\\\\'U}" "┌")
  269.     ("{\\\\^U}" "█")
  270.     ("{\\\\~n}" "±")
  271.     ("{\\\\~N}" "╤")
  272.     ("{\\\\c c}" "τ")
  273.     ("{\\\\c C}" "╟")
  274.     ("\\\\\"a" "Σ")
  275.     ("\\\\`a" "α")
  276.     ("\\\\'a" "ß")
  277.     ("\\\\~a" "π")
  278.     ("\\\\^a" "Γ")
  279.     ("\\\\\"e" "δ")
  280.     ("\\\\`e" "Φ")
  281.     ("\\\\'e" "Θ")
  282.     ("\\\\^e" "Ω")
  283.     ("\\\\\"\\\\i" "∩")
  284.     ("\\\\`\\\\i" "∞")
  285.     ("\\\\'\\\\i" "φ")
  286.     ("\\\\^\\\\i" "ε")
  287.     ("\\\\\"i" "∩")
  288.     ("\\\\`i" "∞")
  289.     ("\\\\'i" "φ")
  290.     ("\\\\^i" "ε")
  291.     ("\\\\\"o" "÷")
  292.     ("\\\\`o" "≥")
  293.     ("\\\\'o" "≤")
  294.     ("\\\\~o" "⌡")
  295.     ("\\\\^o" "⌠")
  296.     ("\\\\\"u" "ⁿ")
  297.     ("\\\\`u" "∙")
  298.     ("\\\\'u" "·")
  299.     ("\\\\^u" "√")
  300.     ("\\\\\"A" "─")
  301.     ("\\\\`A" "└")
  302.     ("\\\\'A" "┴")
  303.     ("\\\\~A" "├")
  304.     ("\\\\^A" "┬")
  305.     ("\\\\\"E" "╦")
  306.     ("\\\\`E" "╚")
  307.     ("\\\\'E" "╔")
  308.     ("\\\\^E" "╩")
  309.     ("\\\\\"I" "╧")
  310.     ("\\\\`I" "╠")
  311.     ("\\\\'I" "═")
  312.     ("\\\\^I" "╬")
  313.     ("\\\\\"O" "╓")
  314.     ("\\\\`O" "╥")
  315.     ("\\\\'O" "╙")
  316.     ("\\\\~O" "╒")
  317.     ("\\\\^O" "╘")
  318.     ("\\\\\"U" "▄")
  319.     ("\\\\`U" "┘")
  320.     ("\\\\'U" "┌")
  321.     ("\\\\^U" "█")
  322.     ("\\\\~n" "±")
  323.     ("\\\\~N" "╤")
  324.     ("\\\\\"{a}" "Σ")
  325.     ("\\\\`{a}" "α")
  326.     ("\\\\'{a}" "ß")
  327.     ("\\\\~{a}" "π")
  328.     ("\\\\^{a}" "Γ")
  329.     ("\\\\\"{e}" "δ")
  330.     ("\\\\`{e}" "Φ")
  331.     ("\\\\'{e}" "Θ")
  332.     ("\\\\^{e}" "Ω")
  333.     ("\\\\\"{\\\\i}" "∩")
  334.     ("\\\\`{\\\\i}" "∞")
  335.     ("\\\\'{\\\\i}" "φ")
  336.     ("\\\\^{\\\\i}" "ε")
  337.     ("\\\\\"{i}" "∩")
  338.     ("\\\\`{i}" "∞")
  339.     ("\\\\'{i}" "φ")
  340.     ("\\\\^{i}" "ε")
  341.     ("\\\\\"{o}" "÷")
  342.     ("\\\\`{o}" "≥")
  343.     ("\\\\'{o}" "≤")
  344.     ("\\\\~{o}" "⌡")
  345.     ("\\\\^{o}" "⌠")
  346.     ("\\\\\"{u}" "ⁿ")
  347.     ("\\\\`{u}" "∙")
  348.     ("\\\\'{u}" "·")
  349.     ("\\\\^{u}" "√")
  350.     ("\\\\\"{A}" "─")
  351.     ("\\\\`{A}" "└")
  352.     ("\\\\'{A}" "┴")
  353.     ("\\\\~{A}" "├")
  354.     ("\\\\^{A}" "┬")
  355.     ("\\\\\"{E}" "╦")
  356.     ("\\\\`{E}" "╚")
  357.     ("\\\\'{E}" "╔")
  358.     ("\\\\^{E}" "╩")
  359.     ("\\\\\"{I}" "╧")
  360.     ("\\\\`{I}" "╠")
  361.     ("\\\\'{I}" "═")
  362.     ("\\\\^{I}" "╬")
  363.     ("\\\\\"{O}" "╓")
  364.     ("\\\\`{O}" "╥")
  365.     ("\\\\'{O}" "╙")
  366.     ("\\\\~{O}" "╒")
  367.     ("\\\\^{O}" "╘")
  368.     ("\\\\\"{U}" "▄")
  369.     ("\\\\`{U}" "┘")
  370.     ("\\\\'{U}" "┌")
  371.     ("\\\\^{U}" "█")
  372.     ("\\\\~{n}" "±")
  373.     ("\\\\~{N}" "╤")
  374.     ("\\\\c{c}" "τ")
  375.     ("\\\\c{C}" "╟")
  376.     ("{\\\\ss}" "▀")
  377.     ("{\\\\AE}" "\306")
  378.     ("{\\\\ae}" "\346")
  379.     ("{\\\\AA}" "\305")
  380.     ("{\\\\aa}" "\345")
  381.     ("{\\\\copyright}" "\251")
  382.     ("\\\\copyright{}" "\251")
  383.     ("{\\\\pounds}" "ú" )
  384.     ("{\\\\P}" "╢" )
  385.     ("{\\\\S}" "º" )
  386.     ("\\\\pounds{}" "ú" )
  387.     ("\\\\P{}" "╢" )
  388.     ("\\\\S{}" "º" )
  389.     ("{\\?`}" "┐")
  390.     ("{!`}" "í")
  391.     ("\\?`" "┐")
  392.     ("!`" "í")
  393.     )
  394.   "Translation table for translating TeX sequences to ISO 8859-1 characters. 
  395. This table is not exhaustive (and due to TeX's power can never be). It only
  396. contains commonly used sequences.")
  397.  
  398. (defun iso-tex2iso ()
  399.  "Translate TeX sequences to ISO 8859-1 characters."
  400.  (interactive)
  401.  (iso-translate-conventions iso-tex2iso-trans-tab))
  402.  
  403. (defvar iso-gtex2iso-trans-tab
  404.   '(
  405.     ("{\\\\\"a}" "Σ")
  406.     ("{\\\\`a}" "α")
  407.     ("{\\\\'a}" "ß")
  408.     ("{\\\\~a}" "π")
  409.     ("{\\\\^a}" "Γ")
  410.     ("{\\\\\"e}" "δ")
  411.     ("{\\\\`e}" "Φ")
  412.     ("{\\\\'e}" "Θ")
  413.     ("{\\\\^e}" "Ω")
  414.     ("{\\\\\"\\\\i}" "∩")
  415.     ("{\\\\`\\\\i}" "∞")
  416.     ("{\\\\'\\\\i}" "φ")
  417.     ("{\\\\^\\\\i}" "ε")
  418.     ("{\\\\\"i}" "∩")
  419.     ("{\\\\`i}" "∞")
  420.     ("{\\\\'i}" "φ")
  421.     ("{\\\\^i}" "ε")
  422.     ("{\\\\\"o}" "÷")
  423.     ("{\\\\`o}" "≥")
  424.     ("{\\\\'o}" "≤")
  425.     ("{\\\\~o}" "⌡")
  426.     ("{\\\\^o}" "⌠")
  427.     ("{\\\\\"u}" "ⁿ")
  428.     ("{\\\\`u}" "∙")
  429.     ("{\\\\'u}" "·")
  430.     ("{\\\\^u}" "√")
  431.     ("{\\\\\"A}" "─")
  432.     ("{\\\\`A}" "└")
  433.     ("{\\\\'A}" "┴")
  434.     ("{\\\\~A}" "├")
  435.     ("{\\\\^A}" "┬")
  436.     ("{\\\\\"E}" "╦")
  437.     ("{\\\\`E}" "╚")
  438.     ("{\\\\'E}" "╔")
  439.     ("{\\\\^E}" "╩")
  440.     ("{\\\\\"I}" "╧")
  441.     ("{\\\\`I}" "╠")
  442.     ("{\\\\'I}" "═")
  443.     ("{\\\\^I}" "╬")
  444.     ("{\\\\\"O}" "╓")
  445.     ("{\\\\`O}" "╥")
  446.     ("{\\\\'O}" "╙")
  447.     ("{\\\\~O}" "╒")
  448.     ("{\\\\^O}" "╘")
  449.     ("{\\\\\"U}" "▄")
  450.     ("{\\\\`U}" "┘")
  451.     ("{\\\\'U}" "┌")
  452.     ("{\\\\^U}" "█")
  453.     ("{\\\\~n}" "±")
  454.     ("{\\\\~N}" "╤")
  455.     ("{\\\\c c}" "τ")
  456.     ("{\\\\c C}" "╟")
  457.     ("\\\\\"a" "Σ")
  458.     ("\\\\`a" "α")
  459.     ("\\\\'a" "ß")
  460.     ("\\\\~a" "π")
  461.     ("\\\\^a" "Γ")
  462.     ("\\\\\"e" "δ")
  463.     ("\\\\`e" "Φ")
  464.     ("\\\\'e" "Θ")
  465.     ("\\\\^e" "Ω")
  466.     ("\\\\\"\\\\i" "∩")
  467.     ("\\\\`\\\\i" "∞")
  468.     ("\\\\'\\\\i" "φ")
  469.     ("\\\\^\\\\i" "ε")
  470.     ("\\\\\"i" "∩")
  471.     ("\\\\`i" "∞")
  472.     ("\\\\'i" "φ")
  473.     ("\\\\^i" "ε")
  474.     ("\\\\\"o" "÷")
  475.     ("\\\\`o" "≥")
  476.     ("\\\\'o" "≤")
  477.     ("\\\\~o" "⌡")
  478.     ("\\\\^o" "⌠")
  479.     ("\\\\\"u" "ⁿ")
  480.     ("\\\\`u" "∙")
  481.     ("\\\\'u" "·")
  482.     ("\\\\^u" "√")
  483.     ("\\\\\"A" "─")
  484.     ("\\\\`A" "└")
  485.     ("\\\\'A" "┴")
  486.     ("\\\\~A" "├")
  487.     ("\\\\^A" "┬")
  488.     ("\\\\\"E" "╦")
  489.     ("\\\\`E" "╚")
  490.     ("\\\\'E" "╔")
  491.     ("\\\\^E" "╩")
  492.     ("\\\\\"I" "╧")
  493.     ("\\\\`I" "╠")
  494.     ("\\\\'I" "═")
  495.     ("\\\\^I" "╬")
  496.     ("\\\\\"O" "╓")
  497.     ("\\\\`O" "╥")
  498.     ("\\\\'O" "╙")
  499.     ("\\\\~O" "╒")
  500.     ("\\\\^O" "╘")
  501.     ("\\\\\"U" "▄")
  502.     ("\\\\`U" "┘")
  503.     ("\\\\'U" "┌")
  504.     ("\\\\^U" "█")
  505.     ("\\\\~n" "±")
  506.     ("\\\\~N" "╤")
  507.     ("\\\\\"{a}" "Σ")
  508.     ("\\\\`{a}" "α")
  509.     ("\\\\'{a}" "ß")
  510.     ("\\\\~{a}" "π")
  511.     ("\\\\^{a}" "Γ")
  512.     ("\\\\\"{e}" "δ")
  513.     ("\\\\`{e}" "Φ")
  514.     ("\\\\'{e}" "Θ")
  515.     ("\\\\^{e}" "Ω")
  516.     ("\\\\\"{\\\\i}" "∩")
  517.     ("\\\\`{\\\\i}" "∞")
  518.     ("\\\\'{\\\\i}" "φ")
  519.     ("\\\\^{\\\\i}" "ε")
  520.     ("\\\\\"{i}" "∩")
  521.     ("\\\\`{i}" "∞")
  522.     ("\\\\'{i}" "φ")
  523.     ("\\\\^{i}" "ε")
  524.     ("\\\\\"{o}" "÷")
  525.     ("\\\\`{o}" "≥")
  526.     ("\\\\'{o}" "≤")
  527.     ("\\\\~{o}" "⌡")
  528.     ("\\\\^{o}" "⌠")
  529.     ("\\\\\"{u}" "ⁿ")
  530.     ("\\\\`{u}" "∙")
  531.     ("\\\\'{u}" "·")
  532.     ("\\\\^{u}" "√")
  533.     ("\\\\\"{A}" "─")
  534.     ("\\\\`{A}" "└")
  535.     ("\\\\'{A}" "┴")
  536.     ("\\\\~{A}" "├")
  537.     ("\\\\^{A}" "┬")
  538.     ("\\\\\"{E}" "╦")
  539.     ("\\\\`{E}" "╚")
  540.     ("\\\\'{E}" "╔")
  541.     ("\\\\^{E}" "╩")
  542.     ("\\\\\"{I}" "╧")
  543.     ("\\\\`{I}" "╠")
  544.     ("\\\\'{I}" "═")
  545.     ("\\\\^{I}" "╬")
  546.     ("\\\\\"{O}" "╓")
  547.     ("\\\\`{O}" "╥")
  548.     ("\\\\'{O}" "╙")
  549.     ("\\\\~{O}" "╒")
  550.     ("\\\\^{O}" "╘")
  551.     ("\\\\\"{U}" "▄")
  552.     ("\\\\`{U}" "┘")
  553.     ("\\\\'{U}" "┌")
  554.     ("\\\\^{U}" "█")
  555.     ("\\\\~{n}" "±")
  556.     ("\\\\~{N}" "╤")
  557.     ("\\\\c{c}" "τ")
  558.     ("\\\\c{C}" "╟")
  559.     ("{\\\\ss}" "▀")
  560.     ("{\\\\AE}" "\306")
  561.     ("{\\\\ae}" "\346")
  562.     ("{\\\\AA}" "\305")
  563.     ("{\\\\aa}" "\345")
  564.     ("{\\\\copyright}" "\251")
  565.     ("\\\\copyright{}" "\251")
  566.     ("{\\\\pounds}" "ú" )
  567.     ("{\\\\P}" "╢" )
  568.     ("{\\\\S}" "º" )
  569.     ("\\\\pounds{}" "ú" )
  570.     ("\\\\P{}" "╢" )
  571.     ("\\\\S{}" "º" )
  572.     ("?`" "┐")
  573.     ("!`" "í")
  574.     ("{?`}" "┐")
  575.     ("{!`}" "í")
  576.     ("\"a" "Σ")
  577.     ("\"A" "─")
  578.     ("\"o" "÷")
  579.     ("\"O" "╓")
  580.     ("\"u" "ⁿ")
  581.     ("\"U" "▄")
  582.     ("\"s" "▀")
  583.     ("\\\\3" "▀")
  584.     )
  585.   "Translation table for translating German TeX sequences to ISO 8859-1.
  586. This table is not exhaustive (and due to TeX's power can never be).  It only
  587. contains commonly used sequences.")
  588.  
  589. (defvar iso-iso2gtex-trans-tab
  590.   '(
  591.     ("Σ" "\"a")
  592.     ("α" "{\\\\`a}")
  593.     ("ß" "{\\\\'a}")
  594.     ("π" "{\\\\~a}")
  595.     ("Γ" "{\\\\^a}")
  596.     ("δ" "{\\\\\"e}")
  597.     ("Φ" "{\\\\`e}")
  598.     ("Θ" "{\\\\'e}")
  599.     ("Ω" "{\\\\^e}")
  600.     ("∩" "{\\\\\"\\\\i}")
  601.     ("∞" "{\\\\`\\\\i}")
  602.     ("φ" "{\\\\'\\\\i}")
  603.     ("ε" "{\\\\^\\\\i}")
  604.     ("÷" "\"o")
  605.     ("≥" "{\\\\`o}")
  606.     ("≤" "{\\\\'o}")
  607.     ("⌡" "{\\\\~o}")
  608.     ("⌠" "{\\\\^o}")
  609.     ("ⁿ" "\"u")
  610.     ("∙" "{\\\\`u}")
  611.     ("·" "{\\\\'u}")
  612.     ("√" "{\\\\^u}")
  613.     ("─" "\"A")
  614.     ("└" "{\\\\`A}")
  615.     ("┴" "{\\\\'A}")
  616.     ("├" "{\\\\~A}")
  617.     ("┬" "{\\\\^A}")
  618.     ("╦" "{\\\\\"E}")
  619.     ("╚" "{\\\\`E}")
  620.     ("╔" "{\\\\'E}")
  621.     ("╩" "{\\\\^E}")
  622.     ("╧" "{\\\\\"I}")
  623.     ("╠" "{\\\\`I}")
  624.     ("═" "{\\\\'I}")
  625.     ("╬" "{\\\\^I}")
  626.     ("╓" "\"O")
  627.     ("╥" "{\\\\`O}")
  628.     ("╙" "{\\\\'O}")
  629.     ("╒" "{\\\\~O}")
  630.     ("╘" "{\\\\^O}")
  631.     ("▄" "\"U")
  632.     ("┘" "{\\\\`U}")
  633.     ("┌" "{\\\\'U}")
  634.     ("█" "{\\\\^U}")
  635.     ("±" "{\\\\~n}")
  636.     ("╤" "{\\\\~N}")
  637.     ("τ" "{\\\\c c}")
  638.     ("╟" "{\\\\c C}")
  639.     ("▀" "\"s")
  640.     ("\306" "{\\\\AE}")
  641.     ("\346" "{\\\\ae}")
  642.     ("\305" "{\\\\AA}")
  643.     ("\345" "{\\\\aa}")
  644.     ("\251" "{\\\\copyright}")
  645.     ("ú" "{\\\\pounds}")
  646.     ("╢" "{\\\\P}")
  647.     ("º" "{\\\\S}")
  648.     ("┐" "{?`}")
  649.     ("í" "{!`}")
  650.     )
  651.   "Translation table for translating ISO 8859-1 characters to German TeX.")
  652.  
  653. (defun iso-gtex2iso ()
  654.  "Translate German TeX sequences to ISO 8859-1 characters."
  655.  (interactive)
  656.  (iso-translate-conventions iso-gtex2iso-trans-tab))
  657.  
  658.  
  659. (defun iso-iso2gtex ()
  660.  "Translate ISO 8859-1 characters to German TeX sequences."
  661.  (interactive)
  662.  (iso-translate-conventions iso-iso2gtex-trans-tab))
  663.  
  664.  
  665. (defun iso-german-tex-p ()
  666.  "Check if tex buffer is German LaTeX."
  667.  (save-excursion
  668.    (save-restriction
  669.      (widen)
  670.      (goto-char (point-min))
  671.      (re-search-forward "\\\\documentstyle\\[.*german.*\\]" nil t))))
  672.  
  673. (defun iso-fix-iso2tex ()
  674.   "Turn ISO 8859-1 (aka. ISO Latin-1) buffer into TeX sequences.
  675. If German TeX is used, German TeX sequences are generated."
  676.   (if (or (equal major-mode 'latex-mode)
  677.       (equal major-mode 'LaTeX-mode)) ; AucTeX wants this
  678.       (if (iso-german-tex-p)
  679.       (iso-iso2gtex)
  680.     (iso-iso2tex)))
  681.   (if (or (equal major-mode 'tex-mode)
  682.       (equal major-mode 'TeX-mode) ; AucTeX wants this
  683.       (equal major-mode 'plain-tex-mode))
  684.       (iso-iso2tex)))
  685.  
  686. (defun iso-fix-tex2iso ()
  687.   "Turn TeX sequences into ISO 8859-1 (aka. ISO Latin-1) characters.
  688. This function recognizes German TeX buffers."
  689.   (if (or (equal major-mode 'latex-mode)
  690.       (equal major-mode 'Latex-mode)) ; AucTeX wants this
  691.       (if (iso-german-tex-p)
  692.       (iso-gtex2iso)
  693.     (iso-tex2iso)))
  694.   (if (or (equal major-mode 'tex-mode)
  695.       (equal major-mode 'TeX-mode)  ; AucTeX wants this
  696.       (equal major-mode 'plain-tex-mode))
  697.       (iso-tex2iso)))
  698.  
  699. (defun iso-cvt-ffh ()
  700.   "find-file-hook for iso-cvt.el."
  701.   (iso-fix-tex2iso)
  702.   (set-buffer-modified-p nil))
  703.  
  704. (defun iso-cvt-wfh ()
  705.   "write file hook for iso-cvt.el."
  706.   (iso-fix-iso2tex))
  707.  
  708. (defun iso-cvt-ash ()
  709.   "after save hook for iso-cvt.el."
  710.   (iso-fix-tex2iso)
  711.   (set-buffer-modified-p nil))
  712.  
  713. (add-hook 'find-file-hooks 'iso-cvt-ffh)
  714. (add-hook 'write-file-hooks 'iso-cvt-wfh)
  715. (add-hook 'after-save-hook 'iso-cvt-ash)
  716.  
  717. ;;; iso-cvt.el ends here
  718.